import {defineConfig, loadEnv} from "vite";

import viteDevConfig from "./vite.dev.config";
import viteProdConfig from "./vite.prod.config";
import viteBaseConfig from "./vite.base.config";

//策略模式  => 不同的环境返回不同的配置
const envResolver = {
    "build": () => {
        return {...viteBaseConfig, ...viteProdConfig};
    },
    "serve": () => {
        return {...viteBaseConfig, ...viteDevConfig};
    }
}

export default defineConfig(({command,mode})=> {
    //处理环境变量
    const envGlobal = loadEnv(mode,process.cwd())
    return envResolver[command]();
})



